
import { VuexModule, Module, Action, Mutation, getModule, MutationAction } from 'vuex-module-decorators';
import store from '@/store';
import servers from '@/servers/index'
// interface
// export interface AuxiliaryMonitorState {
//   activeRouter: number;
//   stationName: string;
//   thresholdvalueBtn: number
// }

@Module({ dynamic: true, store, name: 'ParameterManagement', namespaced: true })
class ParameterManagement extends VuexModule {
    // state
    TreeId: string = '';
    ssdsId:any=''
    clickTreeobj:any=''
    tableList={}
   public treeSbIdName:any = {
   };
    //  getter （直接获取）
    getDeviceTypeList: any = [];//公共方法，下拉框-获取设备类型
    getAreaList: any = [];//公共方法，下拉框-获取所属区域名称
    getPointTypeList: any = [] //公共方法， 下拉框-获取测点类型
    getSystemList: any = [] //公共方法，下拉框-获取所属系统名称
    getRigthList:any={}
    //get
    get getterTreeId() {
        return this.TreeId
    }
    @Mutation
    getssdsId(ssdsId: string) {
            this.ssdsId = ssdsId;
            console.log(this.ssdsId);
    }
    @Mutation
    getTreeobj(clickTreeobj: string) {
            this.clickTreeobj = clickTreeobj;
            console.log(this.clickTreeobj);
    }
    //   Action
    @Action({ commit: 'setTreeId' })
    getTreeId(TreeId: string) {
        return TreeId;
    }

    // Mutation
    @Mutation
    setTreeId(TreeId: string) {
        // this.TreeId = '';
        // setTimeout(() => {
            this.TreeId = TreeId;
        // },10)
    }

    @Action({ commit: 'settreeSbId' })
    gettreeSbId(treeSbId: any) {
        return treeSbId;
    }
    @Mutation
    settreeSbId(treeSbId: string) {

        this.treeSbIdName = treeSbId;
        // console.log(this.treeSbIdName );
    }
    //公共方法，下拉框-获取设备类型
    @MutationAction({ mutate: ['getDeviceTypeList'] })
    async getDeviceType() {
        var list: any = await (servers as any)
            .getDeviceType({ data: {} }).then((res: any) => {
                console.log(res);
                return res.data
            })
        // console.log(list);

        return { getDeviceTypeList: list }
    }
    //公共方法，下拉框-获取所属区域名称
    @MutationAction({ mutate: ['getAreaList'] })
    async getgetArea() {
        var list: any = await (servers as any)
            .getArea({ data: {} }).then((res: any) => {
                //   console.log(res);
                return res.data
            })
        // console.log(list);

        return { getAreaList: list }
    }

    //公共方法， 下拉框-获取测点类型
    @MutationAction({ mutate: ['getPointTypeList'] })
    async getgetPointType() {
        var list: any = await (servers as any)
            .getPointType({ data: {} }).then((res: any) => {
                console.log(res);
                return res.data
            })
        // console.log(list);

        return { getPointTypeList: list }
    }
    //公共方法，下拉框-获取所属系统名称
    @MutationAction({ mutate: ['getSystemList'] })
    async getgetSystem() {
        var list: any = await (servers as any)
            .getSystem({ data: {} }).then((res: any) => {
                // console.log(res);
                return res.data
            })

        return { getSystemList: list }
    }
    //公共方法，右侧列表
    @MutationAction({ mutate: ['getRigthList'] })
    async getRigthListArea(form) {
        console.log(form);
        var list =''
        await (servers as any)
              .selectBdzList({ data: form ,method:'post'})
              .then((result: any) => {
                list=result.data
              })
              .catch((err: object) => {
                console.log(err);
              });
        
        // console.log(list);

        return { getRigthList: list }
    }
}

export const ParameterManagementModule = getModule(ParameterManagement);
